using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SubSonic;

public partial class Controls_header : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Query q = Gospel.DB.Article.CreateQuery();
            q.WHERE(Gospel.DB.Article.Columns.FatherId, 0);
            PageBase page = (PageBase)this.Page;
            if (page.pageCulture == "cn")
            {
                q.SelectList = Gospel.DB.Article.Columns.ArticleId + "," + Gospel.DB.Article.Columns.ArticleTitleCn + " as article_title";
            }
            else
            {
                q.SelectList = Gospel.DB.Article.Columns.ArticleId + "," + Gospel.DB.Article.Columns.ArticleTitleTw + " as article_title";
            }
            DataSet ds = new DataSet();
            ds = q.ExecuteDataSet();

            try
            {
                DataTable dt = new DataTable();
                dt = ds.Tables[0];
                this.menuRepeater.DataSource = ds.Tables[0].DefaultView;
                this.menuRepeater.DataBind();
            }
            catch { }
        }
    }

    protected void DirectPage(object sender, CommandEventArgs e)
    {
        string culture = Utility.GetCulture(this.Page);
        if (e.CommandArgument.ToString() == "home")
        {
            Response.Redirect("~/default.aspx?" + culture);
        }
        else
        {
            Response.Redirect("~/Article.aspx?" + culture + "&id=" + e.CommandArgument.ToString());
        }
    }
}
